package com.lty.zyq.controller;


import com.lty.zyq.entity.jsonBean.*;
import com.lty.zyq.service.MealOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/meal")
public class MealController {

    @Autowired
    MealOrderService mealOrderService;





    @GetMapping("/{userId}")
    TodayOrdersStateBean getTodayOrderState(@PathVariable Long userId) {
        return mealOrderService.getTodayOrderState(userId);
    }

    @GetMapping("/{userId}/{whichMeal}/_departmentState")
    List<DepartmentOrderState> getDepartmentState(@PathVariable Long userId, @PathVariable Integer whichMeal) {

        return mealOrderService.getDepartmentState(userId,whichMeal);
    }


    @PostMapping("/")
    OrderStateBean saveOrder(@RequestBody UserOrderBean userOrderBean) {
        return mealOrderService.saveOrder(userOrderBean);
    }

    @PostMapping("/{whichMeal}")
    void helpOrders( @PathVariable Integer whichMeal,@RequestBody List<HelpOrderBean> helpOrderBeans){
        mealOrderService.helpOrders(whichMeal,helpOrderBeans);
    }

}
